<%@page import="dao.MsgDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="model.Fdy" %>
<%@ page import="java.util.List" %>


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>辅导员页面</title>

<link href="../css/Utils.css" rel="stylesheet" type="text/css" />
<link href="../css/List.css" rel="stylesheet" type="text/css" />

</head>
<body>

<!-- 头部 -->
<div class="header" ><br>
<nerong>&nbsp;&nbsp;辅导员页面&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</nerong>

 <button onclick="confirmLogout('<%= (String)session.getAttribute("admin") %>','admin')">退出登录</button>

</div><br>

<div class="left" >
<table width="80%" height="80%">
<th>
<nerong>辅导员可选择内容</nerong>

</th>
<tr>

<td bgcolor=#1a7dba>
<a>&emsp;个人信息</a><br>
</td>
</tr>

<tr>
<td>
<a href = "../View_SuShe/SuSheFDY_List.jsp">&emsp;学生宿舍信息查询</a><br>
</td>
</tr>
<tr>

<td>
<a href = "../View_WeiGui/WeiGuiFDY.jsp">&emsp;宿舍违规信息查询</a><br>

</td>
</tr>

<tr>
<td>
<a href = "../View_leave/T_leave.jsp">&emsp;请假信息处理</a><br>
</td>
</tr>

</table>


</div>



<div class="context" >
<!-- 这部分是每个大功能的小功能 -->
 <!-- 省略了部分HTML和CSS，为了简洁 -->
<table class="Alltable">
    个人信息<br>

<%
    List<String> myList = (List<String>) session.getAttribute("fdy");
    if (myList != null && myList.size() >= 4) {
        String id = myList.get(0);
        session.setAttribute("user", id);

        MsgDao dao = new MsgDao();
        List<Fdy> users = dao.getAloneFdyMessage(id);

        if (users != null && !users.isEmpty()) {
            Fdy user = users.get(0); // 假设我们只关心第一个用户

            // 显示用户ID和姓名（只显示一次）
            out.println(id);
            out.println(user.getName());
            out.println("<br>");

            // 显示班级信息
            for (int i = 1; i < 5 && i < myList.size(); i++) {
                out.println("班级:" + myList.get(i) + "<br>");
            }

            // 显示更改密码按钮（只显示一次）
            out.println("<button onclick=\"location.href='../View_Msg/resetpsw.jsp?id=" + user.getId() + "'\">更改密码</button><br>");

        } else {
%>
        <tr>
            <td colspan="4" style="text-align:center; color:red;">没有找到个人信息</td>
        </tr>
<%
        }
    } else {
%>
        <tr>
            <td colspan="4" style="text-align:center; color:red;">会话数据不完整或格式错误</td>
        </tr>
<%
    }

    String error = (String) request.getAttribute("error");
    if (error != null) {
%>
        <tr>
            <td colspan="4" style="text-align:center; color:red;"><%= error %></td>
        </tr>
<%
    }
%>
</table>

</div>

</body>
</html>